#include <avr/io.h>


void usartDriver_init(unsigned int baud){
UCSR0B |= (1<<TXEN0) | (1<<RXEN0) | (1<<RXCIE0);

UBRR0H = (unsigned char)(baud>>8);
UBRR0L = (unsigned char)baud;

/* Set frame format: 8data, 2stop bit */
UCSR0C = (1<<URSEL0)|(1<<USBS0)|(3<<UCSZ10);
}

int usartDriver_transmit(unsigned char data){
	while (!(UCSR0A & (1 << UDRE0)))
	{	
	}
	
	UDR0 = data;	
	
}	


unsigned char usartDriver_receive(void){
	while ( !(UCSR0A & (1<<RXC0)) )
	{
	}
	
	return UDR0;	
}